//获取验证码
$('.smscode').bind('tap', function() {
	console.log($('.smscode').attr("disabled"))
	if($('.smscode').attr("disabled") == 'disabled') {
		mui.toast("请稍后再试")
		return
	}
	if($("#account").val() == "") {
		mui.toast("手机号不能为空")
		$('#smscode').blur()
		$('#account').focus()
		return;
	}
	if(!isPoneAvailable($("#account").val())) {
		mui.toast("请输入正确的手机号")
		return
	}
	var rndTime = new Date().getTime();
	var str = $("#account").val();
	var codeNum = str.substring(5);
	var validStr = hex_md5(
		codeNum +
		hex_md5(str) +
		rndTime +
		"352c51da88c653c83326941fca5f83b5"
	);
	var parms = {
		phone: $("#account").val(),
		validStr: validStr,
		rndTime: rndTime
	}
	postServer('/app/sms/sendSms', $.param(parms), function(res) {
		console.log(JSON.stringify(res))
		//				console.log(res.data.code)
		if(res.success) {
			mui.toast("请注意查收短信")
			invokeSettime('.smscode')
		} else {
			mui.toast(res.message)
		}
	});
})
//忘记密码
$('.mui-btn-block').bind("tap", function() {
	if($("#account").val() == "") {
		mui.toast("手机号不能为空")
		return;
	}
	//校验重复密码是否一致
	if($("#password").val() == "") {
		mui.toast("密码为空")
		return;
	}
	if($("#password").val() != $("#repassword").val()) {
		mui.toast("两次密码不一致")
		return;
	}
	if($("#smscode").val() == "") {
		mui.toast("验证码为空")
		return;
	}
	var subData =  {
		phone: $("#account").val(),
		password: $("#password").val(),
		rePassword: $("#repassword").val(),
		smsCode: $("#smscode").val(),
	}
	postServer('/app/resetPsw',$.param(subData) , function(res) {
		console.log(JSON.stringify(res))
		//				console.log(res.data.code)
		if(res.success){
			mui.toast('修改成功')
			plus.webview.currentWebview().close()
		}
		
	}, function(res) {
		console.log(JSON.stringify(res))
		mui.toast(res.message)
	});
})
$('homebtn').bind('tap',function(){
	plus.webview.close('../landing/login.html');
	plus.webview.currentWebview().close();
})